# Create your views here.
from django.http import HttpResponse
#from django.template import Context, loader
from django.shortcuts import render
from weiaadao.models import *
import weiboTools 
def index(request):
#	template = loader.get_template('weiAA_app/index.html');
#	context = Context()
#	return HttpResponse(template.render(context));
	#unchecked_activity_list = WeiaaActivity.objects.filter(state = 0)
	checked_activity_list = WeiaaActivity.objects.filter(state = 1)
	feeing_activity_list = WeiaaActivity.objects.filter(state = 2)
	finished_activity_list = WeiaaActivity.objects.filter(state = 3)
	activity_list = WeiaaActivity.objects.all()
	unchecked_activity_list = activity_list.filter(state = 0)
	#p = WeiaaActivityPlan.objects.filter(aid__name__exact='activity01')[1]
	#p = unchecked_activity_list[0].weiaaactivityplan_set.all()[0];
	plan_map = {}
	plan_map[unchecked_activity_list[0].name] = unchecked_activity_list[0].weiaaactivityplan_set.all()
	p = plan_map['activity01'][0]
	print 'hello'
	#'name':value
	return render(request,'weiAA_app/index.html',{'unchecked_activity_list':unchecked_activity_list,'checked_activity_list':checked_activity_list,'feeing_activity_list':feeing_activity_list,'finished_activity_list':finished_activity_list,'activity_list':activity_list,'p':p,'plan_map':plan_map,})
def index2(request):
#	template = loader.get_template('weiAA_app/index.html');
#	context = Context()
#	return HttpResponse(template.render(context));
	#unchecked_activity_list = WeiaaActivity.objects.filter(state = 0)
	checked_activity_list = WeiaaActivity.objects.filter(state = 1)
	feeing_activity_list = WeiaaActivity.objects.filter(state = 2)
	finished_activity_list = WeiaaActivity.objects.filter(state = 3)
	activity_list = WeiaaActivity.objects.all()
	unchecked_activity_list = activity_list.filter(state = 0)
	#p = WeiaaActivityPlan.objects.filter(aid__name__exact='activity01')[1]
	#p = unchecked_activity_list[0].weiaaactivityplan_set.all()[0];
	plan_map = {}
	plan_map[unchecked_activity_list[0].name] = unchecked_activity_list[0].weiaaactivityplan_set.all()
	p = plan_map['activity01'][0]
	
	#'name':value
	return render(request,'weiAA_app/index_new.html',{'unchecked_activity_list':unchecked_activity_list,'checked_activity_list':checked_activity_list,'feeing_activity_list':feeing_activity_list,'finished_activity_list':finished_activity_list,'activity_list':activity_list,'p':p,'plan_map':plan_map,})
def test(request):
	return render(request,'weiAA_app/test.html')
def weiboLogin(request):
	return weiboTools.signin()
	# return render(request,'weiAA_app/weiboLogin.html')
def callback(request):

	weiboTools.callback(request)

	return render(request,'weiAA_app/index.html')
